package example;

public class lamadaDemo
{
    //2.静态内部类
    static class Lamada2 implements InterfaceLamada
    {
        @Override
        public void lamada()
        {
            System.out.println("I'm LamadaFunction staticInnerClass");
        }
    }

    public static void main(String[] args)
    {
        //【注意】数据类型是接口
        InterfaceLamada lamadas = new Lamada();
        lamadas.lamada();

        lamadas = new Lamada2();
        lamadas.lamada();

        //3.局部内部类
        class Lamada3 implements InterfaceLamada
        {
            @Override
            public void lamada()
            {
                System.out.println("I'm LamadaFunction partInnerClass");
            }
        }

        lamadas = new Lamada3();
        lamadas.lamada();

        //4.匿名内部类
        lamadas = new InterfaceLamada()
        {
            @Override
            public void lamada()
            {
                System.out.println("I'm LamadaFunction anonymousInnerClass");
            }
        };
        lamadas.lamada();

        //5.用lamada简化
        lamadas = () ->
        {
            System.out.println("I'm LamadaFunction lamadas");
        };
        lamadas.lamada();
    }
}

//定义函数式接口
interface InterfaceLamada
{
    void lamada();
}

//1.实现类
class Lamada implements InterfaceLamada
{
    @Override
    public void lamada()
    {
        System.out.println("I'm LamadaFunction innerClass");
    }
}
